<template>
    <div class="update">
        <h2 style="font-size:25px; padding:0;margin-bottom:30px;">编辑个人信息</h2>

        <div>
            <el-form  status-icon ref="" label-width="100px" class="demo-">
                <el-form-item label="用户名">
                    <el-input type="user_name" v-model="user.user_name"></el-input>
                </el-form-item>

                <el-form-item label="性别">
                    <el-radio-group v-model="user.user_sex" size="medium">
                    <el-radio border label="男"></el-radio>
                    <el-radio border label="女"></el-radio>
                    </el-radio-group>
                </el-form-item>
                
                <el-form-item label="年龄">
                    <el-input type="user_age" v-model="user.user_age" ></el-input>
                </el-form-item>

                <el-form-item label="手机号">
                    <el-input type="user_phone" v-model="user.user_phone"></el-input>
                </el-form-item>

                <el-form-item label="邮箱">
                    <el-input type="user_email" v-model="user.user_email"></el-input>
                </el-form-item>

                <el-form-item>
                    <el-button type="primary" @click="submitForm()">提交</el-button>
                    <router-link to="/center" ><el-button type="primary">返回</el-button></router-link>
                </el-form-item>
            </el-form>
        </div>

    </div>
    
</template>

<script>
export default {
    name:'',
    data(){
      return {
           user:[],
           
      };
    },
    methods: {
      submitForm() {
          this.id=window.localStorage.getItem("uid");
          console.log(this.user.user_name)
          console.log(this.id)
        this.$axios.get(
        "/updateUser.do?user_name="+this.user.user_name 
         +"&user_sex=" +this.user.user_sex
        +"&user_age=" +this.user.user_age 
        +"&user_phone=" +this.user.user_phone
        +"&user_email=" +this.user.user_email
        +"&user_id=" +this.id
        )
       .then((response) => {
           if(response.data>0){
                alert('修改成功!')
           }else{
               alert('修改失败！')
           }
       })
      },

    },
    mounted(){
         this.id=window.localStorage.getItem("uid");
        this.$axios.get("/getUserByid.do?user_id="+this.id).then((response) =>{
            this.user=response.data;
            
        })
    }
}

</script>

<style scoped>
.update{
    width: 80%;
    border: 1px solid #999;
    text-align: center;
    margin: auto;
    margin-top: 100px;
    padding-top: 40px;
    padding-right: 20px;
}
.el-button{
    margin-left: 30px;
}
.el-form-item{
    margin-left: 0px;
}

</style>